﻿
Imports System.Net.Sockets
Imports osi.root.constants
Imports osi.root.utils
Imports osi.service.commander
Imports osi.service.device

Public Class questioner
    Inherits commander.questioner

    Private Shared Function wait_device_timeout_ms(ByVal p As powerpoint) As Int64
        Return If(p Is Nothing, npos, p.connecting_timeout_ms)
    End Function

    Private Shared Function timeout_ms(ByVal p As powerpoint) As Int64
        Return If(p Is Nothing, npos, p.response_timeout_ms)
    End Function

    'for connector, use p as reference
    Friend Sub New(ByVal c As TcpClient, ByVal p As powerpoint)
        MyBase.New(assert_return(Not p Is Nothing, p.as_herald(c)), p.response_timeout_ms)
    End Sub

    Public Sub New(ByVal p As powerpoint)
        MyBase.New(assert_return(Not p Is Nothing, p).herald_device_pool,
                   p.connecting_timeout_ms,
                   p.response_timeout_ms)
    End Sub

    Public Sub New(ByVal name As String)
        Me.New(connection_manager.get(name))
    End Sub
End Class
